<template>
  <div class="vip-container">
    <!-- 顶部装饰波浪 -->
    <div class="wave-container">
      <div class="wave"></div>
    </div>

    <div class="vip-header">
      <div class="header-content">
        <h2 class="vip-title">智文助手超级会员</h2>
        <p class="vip-subtitle">解锁全部高级功能，让创作更轻松</p>
      </div>
    </div>
    
    <div class="vip-cards">
      <!-- 免费版卡片 -->
      <div class="vip-card free">
        <div class="card-badge">免费体验</div>
        <div class="card-header">
          <div class="card-icon">🎯</div>
          <h3>免费版</h3>
        </div>
        <div class="card-price">
          <span class="currency">¥</span>
          <span class="price">0</span>
          <span class="duration">/永久</span>
        </div>
        <div class="card-description">基础AI写作功能</div>
        <ul class="card-features">
          <li><i class="el-icon-check"></i>优质客服服务</li>
          <li><i class="el-icon-check"></i>智能创作，快速生成文章</li>
          <li><i class="el-icon-check"></i>无需费用提升创作效率</li>
          <li><i class="el-icon-check"></i>查看历史对话记录</li>
        </ul>
        <el-button class="action-button current">当前方案</el-button>
      </div>

      <!-- 普通会员卡片 -->
      <div class="vip-card basic">
        <div class="card-badge popular">热门选择</div>
        <div class="card-header">
          <div class="card-icon">⭐</div>
          <h3>普通会员</h3>
        </div>
        <div class="card-price">
          <span class="currency">¥</span>
          <span class="price">10</span>
          <span class="duration">/月</span>
        </div>
        <div class="card-description">解锁进阶写作功能</div>
        <ul class="card-features">
          <li><i class="el-icon-check"></i>解锁全部核心功能模块</li>
          <li><i class="el-icon-check"></i>AI智能算法生成优质内容</li>
          <li><i class="el-icon-check"></i>一键生成高质量文章</li>
          <li><i class="el-icon-check"></i>支持多种论文类型生成</li>
          <li><i class="el-icon-check"></i>严格格式把控与规范性</li>
        </ul>
        <el-button type="primary" class="action-button" @click="select01">立即开通</el-button>
      </div>

      <!-- 超级会员卡片 -->
      <div class="vip-card pro">
        <div class="card-badge premium">尊享特权</div>
        <div class="card-header">
          <div class="card-icon">👑</div>
          <h3>超级会员</h3>
        </div>
        <div class="card-price">
          <span class="currency">¥</span>
          <span class="price">50</span>
          <span class="duration">/月</span>
        </div>
        <div class="card-description">完整商业版功能</div>
        <ul class="card-features">
          <li><i class="el-icon-check"></i>包含普通会员所有功能</li>
          <li><i class="el-icon-check"></i>支持多种格式文档导出</li>
          <li><i class="el-icon-check"></i>PDF、Word等格式转换</li>
          <li><i class="el-icon-check"></i>无限次数文档导出</li>
          <li><i class="el-icon-check"></i>优先使用新功能</li>
        </ul>
        <el-button type="primary" class="action-button premium-button" @click="select02">立即开通</el-button>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ElButton, ElMessage } from 'element-plus' // 引入Element Plus的按钮和消息组件
import { openMember} from "@/api/system/user"; // 引入开通会员的API函数

// 定义一个数据对象，用于存储会员开通的相关信息
const data = {
  packetId: "", // 会员套餐ID
  packetName: "", // 会员套餐名称
  packetPrice: "", // 会员套餐价格
  packetInformation: "" // 会员套餐额外信息（当前未使用）
}

// 选择普通会员的函数
function select01() {
  data.value = {
    packetId: "1",
    packetName: "普通会员",
    packetPrice: "10",
    packetInformation: ""
  }
  openMember(data.value).then(response => {
    if (response.code === 200) {
      ElMessage.success('开通普通会员成功！');
    } else {
      ElMessage.error('开通普通会员失败！');
    }
  })
}

// 选择超级会员的函数
function select02() {
  data.value = {
    packetId: "2",
    packetName: "超级会员",
    packetPrice: "50",
    packetInformation: ""
  }
  openMember(data.value).then(response => {
    if (response.code === 200) {
      ElMessage.success('开通超级会员成功！');
    } else {
      ElMessage.error('开通超级会员失败！');
    }
  })
}
</script>

<style lang="scss" scoped>
.vip-container {
  min-height: 100vh;
  background: linear-gradient(135deg, #f6f9fc 0%, #eef2f7 100%);
  position: relative;
  overflow: hidden;
  padding: 60px 20px;
}

.wave-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  overflow: hidden;
  line-height: 0;
}

.wave {
  position: relative;
  height: 120px;
  background: linear-gradient(60deg, rgba(84,58,183,1) 0%, rgba(0,172,193,1) 100%);
  transform: rotate(180deg);
  
  &:before {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100px;
    background: url('data:image/svg+xml,<svg viewBox="0 0 1200 120" xmlns="http://www.w3.org/2000/svg"><path d="M321.39,56.44c58-10.79,114.16-30.13,172-41.86,82.39-16.72,168.19-17.73,250.45-.39C823.78,31,906.67,72,985.66,92.83c70.05,18.48,146.53,26.09,214.34,3V0H0V27.35A600.21,600.21,0,0,0,321.39,56.44Z"></path></svg>') repeat-x;
    background-size: 1200px 100px;
    animation: wave 10s linear infinite;
  }
}

@keyframes wave {
  0% { background-position-x: 0; }
  100% { background-position-x: 1200px; }
}

.vip-header {
  text-align: center;
  margin-bottom: 40px;
  position: relative;
  z-index: 1;
}

.header-content {
  padding: 15px 30px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  display: inline-block;
  max-width: 400px;
}

.vip-title {
  font-size: 36px;
  font-weight: 800;
  background: linear-gradient(135deg, #2c3e50, #3498db);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 10px;
}

.vip-subtitle {
  font-size: 18px;
  color: #64748b;
  margin-top: 5px;
}

.vip-cards {
  display: flex;
  justify-content: center;
  gap: 30px;
  flex-wrap: wrap;
  max-width: 1200px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.vip-card {
  width: 340px;
  background: white;
  border-radius: 24px;
  padding: 35px;
  position: relative;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
  border: 2px solid transparent;
  
  &:hover {
    transform: translateY(-12px);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
    border-color: #409EFF;
  }

  .card-badge {
    position: absolute;
    top: -15px;
    right: 25px;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    color: white;
    background: #409EFF;
    box-shadow: 0 4px 15px rgba(64, 158, 255, 0.35);
    
    &.popular {
      background: linear-gradient(135deg, #ff9a9e 0%, #fad0c4 99%, #fad0c4 100%);
    }
    
    &.premium {
      background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    }
  }

  .card-header {
    text-align: center;
    margin-bottom: 25px;
    
    .card-icon {
      font-size: 36px;
      margin-bottom: 15px;
    }
    
    h3 {
      font-size: 26px;
      font-weight: 700;
      color: #1a202c;
      margin: 0;
    }
  }

  .card-price {
    text-align: center;
    margin-bottom: 25px;
    
    .currency {
      font-size: 24px;
      font-weight: 600;
      color: #409EFF;
      vertical-align: top;
      margin-right: 4px;
    }
    
    .price {
      font-size: 48px;
      font-weight: 800;
      color: #409EFF;
      line-height: 1;
    }
    
    .duration {
      font-size: 16px;
      color: #718096;
      margin-left: 4px;
    }
  }

  .card-description {
    text-align: center;
    color: #64748b;
    font-size: 16px;
    margin-bottom: 25px;
    padding-bottom: 25px;
    border-bottom: 1px solid #e2e8f0;
  }

  .card-features {
    list-style: none;
    padding: 0;
    margin: 0 0 35px;

    li {
      font-size: 15px;
      line-height: 1.8;
      color: #4a5568;
      margin-bottom: 15px;
      display: flex;
      align-items: center;

      i {
        color: #409EFF;
        margin-right: 12px;
        font-size: 18px;
      }
    }
  }

  .action-button {
    width: 100%;
    height: 50px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 25px;
    transition: all 0.3s ease;
    
    &:hover {
      transform: translateY(-2px);
      box-shadow: 0 7px 20px rgba(64, 158, 255, 0.3);
    }
    
    &.current {
      background: #f8fafc;
      color: #64748b;
      border: 2px solid #e2e8f0;
      
      &:hover {
        background: #f1f5f9;
      }
    }
    
    &.premium-button {
      background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
      border: none;
      
      &:hover {
        box-shadow: 0 7px 20px rgba(102, 126, 234, 0.4);
      }
    }
  }
}

@media (max-width: 768px) {
  .vip-container {
    padding: 40px 15px;
  }

  .vip-title {
    font-size: 32px;
  }

  .vip-subtitle {
    font-size: 18px;
  }

  .vip-cards {
    gap: 20px;
    
    .vip-card {
      width: 100%;
      max-width: 340px;
      padding: 25px;
    }
  }
}
</style>